home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxdcolor.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  6.5 KB  |  186 lines

  1. /* Copyright (C) 1993, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxdcolor.h,v 1.3 2000/09/19 19:00:35 lpd Exp $ */
  20. /* Device color representation for Ghostscript */
  21.  
  22. #ifndef gxdcolor_INCLUDED
  23. #  define gxdcolor_INCLUDED
  24.  
  25. #include "gscsel.h"
  26. #include "gsdcolor.h"
  27. #include "gsropt.h"
  28. #include "gsstruct.h"        /* for extern_st, GC procs */
  29.  
  30. /* Define opaque types. */
  31.  
  32. #ifndef gx_device_DEFINED
  33. #  define gx_device_DEFINED
  34. typedef struct gx_device_s gx_device;
  35.  
  36. #endif
  37.  
  38. /*
  39.  * Define a source structure for RasterOp.
  40.  */
  41. typedef struct gx_rop_source_s {
  42.     const byte *sdata;
  43.     int sourcex;
  44.     uint sraster;
  45.     gx_bitmap_id id;
  46.     gx_color_index scolors[2];
  47.     bool use_scolors;
  48. } gx_rop_source_t;
  49.  
  50. /*
  51.  * Note that the following definition depends on the gx_color_index for
  52.  * black, which may not be 0.  Clients must check this and construct
  53.  * a different null source if necessary.
  54.  */
  55. #define gx_rop_no_source_body(black_pixel)\
  56.   NULL, 0, 0, gx_no_bitmap_id, {black_pixel, black_pixel}, true
  57. #define gx_rop_source_set_color(prs, pixel)\
  58.   ((prs)->scolors[0] = (prs)->scolors[1] = (pixel))
  59. void gx_set_rop_no_source(P3(const gx_rop_source_t **psource,
  60.                  gx_rop_source_t *pno_source, gx_device *dev));
  61. #define set_rop_no_source(source, no_source, dev)\
  62.   gx_set_rop_no_source(&(source), &(no_source), dev)
  63.  
  64. /*
  65.  * Define the device color structure per se.
  66.  */
  67.  
  68. /* The typedef is in gsdcolor.h. */
  69. /*typedef struct gx_device_color_type_s gx_device_color_type_t; */
  70. struct gx_device_color_type_s {
  71.  
  72.     /*
  73.      * In order to simplify memory management, we use a union, but since
  74.      * different variants may have different pointer tracing procedures,
  75.      * we have to define a separate GC structure type for each variant.
  76.      */
  77.  
  78.     gs_memory_type_ptr_t stype;
  79.  
  80.     /*
  81.      * If necessary and possible, load the halftone or Pattern cache
  82.      * with the rendering of this color.
  83.      */
  84.  
  85. #define dev_color_proc_load(proc)\
  86.   int proc(P4(gx_device_color *pdevc, const gs_imager_state *pis,\
  87.     gx_device *dev, gs_color_select_t select))
  88.                          dev_color_proc_load((*load));
  89.  
  90.     /*
  91.      * Fill a rectangle with the color.
  92.      * We pass the device separately so that pattern fills can
  93.      * substitute a tiled mask clipping device.
  94.      */
  95.  
  96. #define dev_color_proc_fill_rectangle(proc)\
  97.   int proc(P8(const gx_device_color *pdevc, int x, int y, int w, int h,\
  98.     gx_device *dev, gs_logical_operation_t lop, const gx_rop_source_t *source))
  99.                          dev_color_proc_fill_rectangle((*fill_rectangle));
  100.  
  101.     /*
  102.      * Fill a masked region with a color.  Nearly all device colors
  103.      * use the default implementation, which simply parses the mask
  104.      * into rectangles and calls fill_rectangle.  Note that in this
  105.      * case there is no RasterOp source: the mask is the source.
  106.      */
  107.  
  108. #define dev_color_proc_fill_masked(proc)\
  109.   int proc(P12(const gx_device_color *pdevc, const byte *data, int data_x,\
  110.     int raster, gx_bitmap_id id, int x, int y, int w, int h,\
  111.     gx_device *dev, gs_logical_operation_t lop, bool invert))
  112.                          dev_color_proc_fill_masked((*fill_masked));
  113.  
  114.     /*
  115.      * Test whether this color is equal to another.
  116.      */
  117.  
  118. #define dev_color_proc_equal(proc)\
  119.   bool proc(P2(const gx_device_color *pdevc1, const gx_device_color *pdevc2))
  120.                          dev_color_proc_equal((*equal));
  121.  
  122. };
  123.  
  124. /* Define the default implementation of fill_masked. */
  125. dev_color_proc_fill_masked(gx_dc_default_fill_masked);
  126.  
  127. extern_st(st_device_color);
  128. /* public_st_device_color() is defined in gsdcolor.h */
  129.  
  130. /* Define the standard device color types. */
  131. /* See gsdcolor.h for details. */
  132. extern const gx_device_color_type_t
  133. #define gx_dc_type_none (&gx_dc_type_data_none)
  134.       gx_dc_type_data_none,    /* gxdcolor.c */
  135. #define gx_dc_type_null (&gx_dc_type_data_null)
  136.       gx_dc_type_data_null,    /* gxdcolor.c */
  137. #define gx_dc_type_pure (&gx_dc_type_data_pure)
  138.       gx_dc_type_data_pure,    /* gxdcolor.c */
  139. /*#define gx_dc_type_pattern (&gx_dc_type_data_pattern) */
  140.                         /*gx_dc_type_data_pattern, *//* gspcolor.c */
  141. #define gx_dc_type_ht_binary (&gx_dc_type_data_ht_binary)
  142.       gx_dc_type_data_ht_binary,    /* gxht.c */
  143. #define gx_dc_type_ht_colored (&gx_dc_type_data_ht_colored)
  144.       gx_dc_type_data_ht_colored;    /* gxcht.c */
  145.  
  146. #define gs_color_writes_pure(pgs)\
  147.   color_writes_pure((pgs)->dev_color, (pgs)->log_op)
  148.  
  149. /* Set up device color 1 for writing into a mask cache */
  150. /* (e.g., the character cache). */
  151. void gx_set_device_color_1(P1(gs_state * pgs));
  152.  
  153. /* Remap the color if necessary. */
  154. int gx_remap_color(P1(gs_state *));
  155.  
  156. #define gx_set_dev_color(pgs)\
  157.   if ( !color_is_set((pgs)->dev_color) )\
  158.    { int code_dc = gx_remap_color(pgs);\
  159.      if ( code_dc != 0 ) return code_dc;\
  160.    }
  161.  
  162. /* Indicate that the device color needs remapping. */
  163. #define gx_unset_dev_color(pgs)\
  164.   color_unset((pgs)->dev_color)
  165.  
  166. /* Load the halftone cache in preparation for drawing. */
  167. #define gx_color_load_select(pdevc, pis, dev, select)\
  168.   (*(pdevc)->type->load)(pdevc, pis, dev, select)
  169. #define gx_color_load(pdevc, pis, dev)\
  170.   gx_color_load_select(pdevc, pis, dev, gs_color_select_texture)
  171. #define gs_state_color_load(pgs)\
  172.   gx_color_load((pgs)->dev_color, (const gs_imager_state *)(pgs),\
  173.         (pgs)->device)
  174.  
  175. /* Fill a rectangle with a color. */
  176. #define gx_device_color_fill_rectangle(pdevc, x, y, w, h, dev, lop, source)\
  177.   (*(pdevc)->type->fill_rectangle)(pdevc, x, y, w, h, dev, lop, source)
  178. #define gx_fill_rectangle_device_rop(x, y, w, h, pdevc, dev, lop)\
  179.   gx_device_color_fill_rectangle(pdevc, x, y, w, h, dev, lop, NULL)
  180. #define gx_fill_rectangle_rop(x, y, w, h, pdevc, lop, pgs)\
  181.   gx_fill_rectangle_device_rop(x, y, w, h, pdevc, (pgs)->device, lop)
  182. #define gx_fill_rectangle(x, y, w, h, pdevc, pgs)\
  183.   gx_fill_rectangle_rop(x, y, w, h, pdevc, (pgs)->log_op, pgs)
  184.  
  185. #endif /* gxdcolor_INCLUDED */
  186.